package cn.yunhe.controller;

import cn.yunhe.entity.User;
import cn.yunhe.services.IUserService;
import cn.yunhe.services.impl.UserService;
import cn.yunhe.utils.BaseAction;
import com.opensymphony.xwork2.ModelDriven;
import lombok.Data;

import java.util.List;

@Data
public class UserListAction extends BaseAction implements ModelDriven {
    private User user;
    IUserService iUserService = new UserService();

    @Override
    public Object getModel() {
        if (user == null) {
            User user = new User();
        }
        return user;
    }

    public String execute() {
        List<User> list = iUserService.userList();
        if (list.size() > 0) {
            getSession().setAttribute("userList", list);
            return "success";
        } else {
            getMapRequest().put("msg","添加用户失败,请<a href='userList.html'>重试<a/>");
            return "error";
        }

    }


}
